#ifndef AUTOPACKAGE_H
#define AUTOPACKAGE_H
#include <string>
#include "issSource.h"

class autoPackage
{
public:
    static autoPackage& getInstance() {
        static autoPackage instance;
        return instance;
    }

    void run(const std::string& myAppname, const std::string& myAppVersion,const std::string& exeName,const std::string& path,const std::string& outputPath);

#ifdef Q_OS_LINUX
    void runAppImagePackaging(const std::string& appName, const std::string& appVersion, 
                             const std::string& exeName, const std::string& appPath, 
                             const std::string& iconPath, const std::string& outputPath,
                             QObject* parent = nullptr);
    void runNonQtAppImagePackaging(const std::string& appName, const std::string& appVersion, 
                                  const std::string& exeName, const std::string& appPath, 
                                  const std::string& iconPath, const std::string& outputPath,
                                  QObject* parent = nullptr);
private:
    void createAppImageScript(const QString& scriptPath);
    void createNonQtAppImageScript(const QString& scriptPath);
public:
#endif

    autoPackage(const autoPackage&) = delete;
    autoPackage& operator=(const autoPackage&) = delete;

private:
    std::string GenerateRFC4122Guid();
    void outputFile(const std::string& originalStr,const std::string& outputPath,const std::string& appName);
    int replaceAndCount(std::string& originalStr,const std::string& oldWord, const std::string& newWord);
    autoPackage() = default;
    static bool first;
};

#endif // AUTOPACKAGE_H
